package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.BankInfoDTO;
import com.zfzs.post.model.dto.WithdrawDTO;
import com.zfzs.post.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 余额管理
 *
 * @author ck
 * @date 2018-11-23
 */
@Slf4j
@RestController
@RequestMapping("balance/")
public class BalanceController {

    @Autowired
    private UserService userService;

    /**
     * 余额提现页面
     */
    @Log("余额提现详情")
    @PostMapping(value = "get_withdraw_info")
    public ResponseResult agetWithdrawInfow() {
        Map<String, Object> res = userService.agetWithdrawInfow();
        return ResponseResult.ok(res);
    }

    /**
     * 修改结算卡号详情
     */
    @Log("修改结算卡号详情")
    @PostMapping(value = "get_sett_card_info")
    public ResponseResult getSettCardInfo() {
        Map<String, Object> res = userService.getSettCardInfo();
        return ResponseResult.ok(res);
    }

    /**
     * 修改结算卡号操作
     */
    @Log("修改结算卡号详情")
    @PostMapping(value = "update_sett_card_info")
    public ResponseResult updateSettCardInfo(@Validated @RequestBody BankInfoDTO dto) {
        userService.updateSettCardInfo(dto);
        return ResponseResult.okMsg("修改成功");
    }

    /**
     * 提现明细
     */
    @Log("提现明细")
    @PostMapping(value = "get_withdraw_list")
    public ResponseResult getWithdrawList() {
        Map<String, Object> res = userService.getWithdrawList();
        return ResponseResult.ok(res);
    }

    /**
     * 提现操作
     */
    @Log("提现操作")
    @PostMapping(value = "withdraw_money")
    public ResponseResult withdrawMoney(@Validated @RequestBody WithdrawDTO dto) {
        userService.withdrawMoney(dto);
        return ResponseResult.okMsg("提现申请成功");
    }
}
